//
//  ViewController.m
//  TableTest
//
//  Created by gn_macMini_liao on 15/12/25.
//  Copyright © 2015年 gn_macMini_liao. All rights reserved.
//

#import "ViewController.h"
#import "LoginTableViewCell.h"

@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 568) style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    
    [self.view addSubview:_tableView];
}
#pragma mark - tableView datasource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    
    return 3;
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSString *cellID = @"loginCell";
    LoginTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    
    if (cell == nil) {
        
        cell = [[LoginTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID row:indexPath.row];
//        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    
    //    cell.textLabel.text = @"dfdf";
    [cell.loginBtn addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    
    return cell;
}

#pragma mark - buttonClick
-(void)buttonClick:(UIButton*)button{
    
    NSLog(@"button.tag == %d",button.tag);
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
    LoginTableViewCell *cell = (LoginTableViewCell *)[_tableView cellForRowAtIndexPath:indexPath];
    
            NSLog(@"_userNameTF == %@",cell.userNameTF.text);
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
